package cn.scm.server.multistage.controller;

import cn.scm.server.multistage.base.ResultDTO;
import cn.scm.server.multistage.entity.BizInviteRecord;
import cn.scm.server.multistage.entity.BizInviteRecordDTO;
import cn.scm.server.multistage.param.BizInviteRecordParam;
import cn.scm.server.multistage.service.BizInviteRecordService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.List;

/**
 * 流转邀请记录表(BizInviteRecord)表控制层
 *
 * @author makejava
 * @since 2020-09-23 20:53:19
 */
@RestController
@RequestMapping("invite/")
@Api(tags = "供应商邀请管理")
public class BizInviteRecordController {
    /**
     * 服务对象
     */
    @Resource
    private BizInviteRecordService bizInviteRecordService;

    /**
     * 通过主键查询单条数据
     *
     * @param id 主键
     * @return 单条数据
     */
    /*@GetMapping("selectOne")
    @ApiOperation("根据Id查询邀请记录")
    public BizInviteRecord selectOne(String id) {
        return this.bizInviteRecordService.queryById(id);
    }*/

    @GetMapping("queryAll")
    @ApiOperation("查询当前公司邀请的所有供应商")
    public ResultDTO<List<BizInviteRecordDTO>> queryAll(@ApiParam(name = "param",value = "过滤参数") @RequestBody BizInviteRecordParam param) {
        ArrayList<BizInviteRecordDTO> bizInviteRecordDTOS = new ArrayList<>();
        return ResultDTO.success(bizInviteRecordDTOS);
    }

    @PostMapping("invite")
    @ApiOperation("邀请供应商")
    public ResultDTO<BizInviteRecordDTO> invite( @RequestBody BizInviteRecordParam param) {
        //TODO 发送短信给供应商，读模板或者用写死的模板，待定
        // 再保存到邀请记录表
        return ResultDTO.success(new BizInviteRecordDTO());
    }

    @PostMapping("reInvite")
    @ApiOperation("重新邀请供应商")
    public ResultDTO reInvite(@ApiParam(value = "邀请记录Id",required = true) @RequestParam("id") String id) {
        // TODO 根据Id读取数据，再发送短信，之后更新邀请记录和更新时间(邀请时间)
        // 再保存到邀请记录表
        return ResultDTO.success();
    }

    @PostMapping("update")
    @ApiOperation("修改邀请状态")
    public ResultDTO update(@ApiParam(value = "邀请记录Id",required = true) @RequestParam("id") String id,
                                                @ApiParam(value = "邀请状态,0:未注册,1:建档审核中,3:建档成功,4:建档退回",required = true) @RequestParam("status") Integer status) {
        // TODO 根据id修改状态和修改时间
        return ResultDTO.success();
    }
}